<!DOCTYPE html>
<html>

<head>
  <title>Admin Login</title>
  <!-- Bootstrap -->
  <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
  <link href="assets/styles.css" rel="stylesheet" media="screen">
  <script src="vendors/jquery-1.9.1.min.js"></script>
  <script src="bootstrap/js/bootstrap.min.js"></script>
  <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
</head>

<body id="login">
  <div class="container">
    <form action="#" class="form-signin" role="form">
      <h2 class="form-signin-heading">用户登录</h2>
      <input id = "username" type="text" class="form-control" placeholder="请输入用户名" required autofocus>
      <div style="height:10px;clear:both;display:block"></div>
      <input id = "password" type="password" class="form-control" placeholder="请输入密码" required>
      <button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
    </form>
  </div>
</body>

</html>

<script>  
  $(document).ready(function () {
    $("button").click(function () {
      //请求参数
      var list = {};
      list.username = $("#username").val();
      list.password = $("#password").val();
      $.ajax({
        type: "POST",
        contentType: "application/json;charset=UTF-8",
        url: "/",
        data: JSON.stringify(list),
        success: function (result) {
          window.location.href="index";
        },
        error: function (e) {
          alert("登陆错误");
        }
      });
    });
  });
</script>